/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.view.symbols;

import java.awt.geom.Rectangle2D;
import org.jfonia.connect5.basics.MutableValueNode;
import org.jfonia.connect5.basics.ValueNode;

/**
 *
 * @author Rik Bauwens
 */
public abstract class ComplexStaffSymbol extends RankedStaffSymbol
{

        protected Rectangle2D rectangle;

        public ComplexStaffSymbol(ValueNode<Double> frameX, ValueNode<Double> staffY,
                                  MutableValueNode<Double> staffBase, MutableValueNode<Double> postStaffBase,
                                  ValueNode<Double> xNode, MutableValueNode<Double> widthNode,
                                  MutableValueNode<Integer> rankNode)
        {
                super(frameX, staffY, staffBase, postStaffBase, xNode, widthNode, rankNode);
                rectangle = new Rectangle2D.Double(getX(), getY(), 0, 0);
        }

        protected void updateNodes()
        {
                preXNode.setValue(getX() - rectangle.getMinX());
                postXNode.setValue(rectangle.getMaxX() - getX());
                preYNode.setValue(getY() - rectangle.getMinY());
                postYNode.setValue(rectangle.getMaxY() - getY());
                requestRepaint();
        }

        protected Rectangle2D getBounds(IStaffSymbol[] symbols)
        {
                Rectangle2D symbolRectangle = new Rectangle2D.Double(getX(), getY(), 0, 0);
                for(IStaffSymbol symbol : symbols)
                        symbolRectangle.add(symbol.getBounds());
                return symbolRectangle;
        }

/*
        @Override
        public double getPreX()
        {
                return super.getPreX() + rectangle.getX() - rectangle.getMinX();
        }

        @Override
        public double getPostX()
        {
                return super.getPostX() + rectangle.getMaxX() - rectangle.getX();
        }

        @Override
        public double getPreY()
        {
                return super.getPreY() + rectangle.getCenterY() - rectangle.getMinY();
        }

        @Override
        public double getPostY()
        {
                return super.getPostY() + rectangle.getMaxY() - rectangle.getCenterY();
        }*/
}
